/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DBManager;

import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;

/**
 * Данный класс обеспечивает коннект к локальной или удалённой БД
 * @author Ivan
 */
public class ConnectManager {
    public final String url;
    public final String user;
    public final String password;
    public Connection connection = null;

    public ConnectManager(String url, String user, String password) {
        this.url = url;
        this.user = user;
        this.password = password;
    }

    public ConnectManager() {
        this.url = "jdbc:mysql://localhost/teamhelperDB";
        this.user = "admin";
        this.password = "123123";
    }

    /**
     * Метод для установления соединения с БД
     * @throws ClassNotFoundException
     * @throws IllegalAccessException
     * @throws InstantiationException
     * @throws SQLException
     */
    public void EstablishAccess() throws ClassNotFoundException,
            IllegalAccessException, InstantiationException, SQLException {

        Class.forName("com.mysql.jdbc.Driver").newInstance();
        connection = DriverManager.getConnection(url, user, password);
    }
}
